#include<bits/stdc++.h>
using namespace std;
struct car{
    int d,v,a;
}c[100005];
int n,m,L,V,p[100005],t=0,ans=1e9;
bool f[100005],vis[100005],ff[100005];
vector<int> id[100005];
void dfs(int dep,int sum){
    if (sum>=ans) return;
    if (dep>m){
        memset(ff,0,sizeof(ff));
        for (int i=1;i<=m;i++){
            if (!vis[i]) continue;
            for (int j=0;j<id[i].size();j++)
                ff[id[i][j]]=1;
        }
        bool fl=1;
        for (int i=1;i<=n;i++){
            if (f[i]&&!ff[i]){
                fl=0;
                break;
            }
        }
        if (fl) ans=min(ans,sum);
        return;
    }
    vis[dep]=0;
    dfs(dep+1,sum);
    vis[dep]=1;
    dfs(dep+1,sum+1);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d%d",&n,&m,&L,&V);
        memset(f,0,sizeof(f));
        for (int i=1;i<=n;i++)
            id[i].clear();
        int flag;
        for (int i=1;i<=n;i++)
            scanf("%d%d%d",&c[i].d,&c[i].v,&c[i].a);
        if (c[1].a==0) flag=0;
        else if (c[1].a>0) flag=1;
        else flag=-1;
        for (int i=2;i<=n;i++){
            if (c[i].a==0&&flag!=0){
                flag=-1;
                break;
            }
            if (c[i].a>0&&flag!=1){
                flag=-1;
                break;
            }
            if (c[i].a<0){
                flag=-1;
                break;
            }
        }
        for (int i=1;i<=m;i++)
            scanf("%d",&p[i]);
        sort(p+1,p+m+1);
        if (flag==0){
            int ANS=0;
            for (int i=1;i<=n;i++)
                if (c[i].v>V&&c[i].d<=p[m]) ANS++;
            if (ANS==0) printf("0 %d\n",m);
            else printf("%d %d\n",ANS,m-1);
            continue;
        }
        if (flag==1){
            int ANS=0;
            for (int i=1;i<=n;i++){
                if (c[i].d>p[m]) continue;
                int d=c[i].d,v=c[i].v,a=c[i].a;
                int k=v*v+2*a*(p[m]-d);
                double vv=sqrt(k);
                if (vv>V) ANS++;
            }
            if (ANS==0) printf("0 %d\n",m);
            else printf("%d %d\n",ANS,m-1);
            continue;
        }
        for (int i=1;i<=n;i++){
            int d=c[i].d,v=c[i].v,a=c[i].a;
            for (int j=1;j<=m;j++){
                if (p[j]<d) continue;
                int k=v*v+2*a*(p[j]-d);
                if (k<0) break;
                double vv=sqrt(k);
                if (vv>V){
                    f[i]=1;
                    id[j].push_back(i);
                }
            }
        }
        t=0;
        for (int i=1;i<=n;i++)
            if (f[i]) t++;
        ans=1e9;
        memset(vis,0,sizeof(vis));
        dfs(1,0);
        printf("%d %d\n",t,m-ans);
    }
    return 0;
}